package com.rowline.admin.module.study.desiremode;

import org.springframework.beans.factory.FactoryBean;

/**
 * ClassName:MyCarFactoryBean
 * Created by 245167
 * on 2017/11/12  12:01
 * description:
 */
public class MyCarFactoryBean implements FactoryBean<Car> {

    private String make;

    private int year;

    public String getMake() {
        return make;
    }

    public void setMake(String make) {
        this.make = make;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    @Override
    public Car getObject() throws Exception {
        Car car  = new Car();

        if(year != 0){
            car.setYear(this.year);
        }

        if("make".equals(make)){
            car.setMake("we are making bla bla bla 。。。");
        }else{
            car.setMake(this.make);
        }

        return car;
    }

    @Override
    public Class<?> getObjectType() {
        return null;
    }

    @Override
    public boolean isSingleton() {
        return false;
    }
}
